/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import control.Control;
import java.awt.Color;
import java.text.DecimalFormat;

/**
 *
 * @author alumneDAM
 */
public class PanelEstadistica extends javax.swing.JPanel {

    /**
     * Creates new form Estadistica
     */
    private Control control;
    
    public PanelEstadistica(Control control) {
        this.control=control;
        initComponents();
    }
    
    public void rellenarProgressBars(int[] porcentajes){

        pb_amarillo.setStringPainted(true);
        pb_amarillo.setForeground(new Color(255, 255, 0));
        pb_amarillo.setBackground(new Color(255, 255, 102));
        pb_amarillo.setValue(porcentajes[0]);
        
        pb_azul.setStringPainted(true);
        pb_azul.setForeground(new Color(0, 0, 153));
        pb_azul.setBackground(Color.BLUE);
        pb_azul.setValue(porcentajes[1]);
        
        pb_gris.setStringPainted(true);
        pb_gris.setForeground(Color.DARK_GRAY);
        pb_gris.setBackground(new Color(160, 160, 160));
        pb_gris.setValue(porcentajes[2]);
        
        pb_marron.setStringPainted(true);
        pb_marron.setForeground(new Color(102, 51, 0));
        pb_marron.setBackground(new Color(179, 95, 12));
        pb_marron.setValue(porcentajes[3]);
        
        pb_naranja.setStringPainted(true);
        pb_naranja.setForeground(new Color(255,128,0));
        pb_naranja.setBackground(Color.ORANGE);
        pb_naranja.setValue(porcentajes[4]);
        
        pb_rosa.setStringPainted(true);
        pb_rosa.setForeground(Color.PINK);
        pb_rosa.setBackground(new Color(255,204,204));
        pb_rosa.setValue(porcentajes[5]);
        
        pb_verde.setStringPainted(true);
        pb_verde.setForeground(Color.GREEN);
        pb_verde.setBackground(new Color(178,255,102));
        pb_verde.setValue(porcentajes[6]);
        
        pb_rojo.setStringPainted(true);
        pb_rojo.setForeground(Color.RED);
        pb_rojo.setBackground(new Color(204,0,0));
        pb_rojo.setValue(porcentajes[7]);
    }

    public void rellenarDatosPartidas(int[] datos){
        //datos[0] = ganadas, datos[1] = totales
        
        this.lbl_ganadas.setText(Integer.toString(datos[0]));
        this.lbl_jugadas.setText(Integer.toString(datos[1]));
        float ratioVictorias = ((float)datos[0] / (float)datos[1] * 100);
        
        DecimalFormat format = new DecimalFormat("0.00");
        
        this.lbl_ratio.setText(format.format(ratioVictorias) + "%");
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel4 = new javax.swing.JLabel();
        jProgressBar8 = new javax.swing.JProgressBar();
        jProgressBar10 = new javax.swing.JProgressBar();
        jProgressBar15 = new javax.swing.JProgressBar();
        jProgressBar18 = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        pb_amarillo = new javax.swing.JProgressBar();
        lbl_jugadas = new javax.swing.JLabel();
        lbl_ganadas = new javax.swing.JLabel();
        lbl_ratio = new javax.swing.JLabel();
        pb_naranja = new javax.swing.JProgressBar();
        pb_azul = new javax.swing.JProgressBar();
        pb_rosa = new javax.swing.JProgressBar();
        pb_gris = new javax.swing.JProgressBar();
        pb_verde = new javax.swing.JProgressBar();
        pb_marron = new javax.swing.JProgressBar();
        pb_rojo = new javax.swing.JProgressBar();

        jLabel4.setText("jLabel4");

        setBackground(new java.awt.Color(204, 204, 204));

        jLabel1.setText("Estadísticas");

        jLabel2.setText("PARTIDAS JUGADAS ");

        jLabel3.setText("PARTIDAS GANADAS");

        jLabel5.setText("PORCENTAJE");

        lbl_jugadas.setText("jLabel7");

        lbl_ganadas.setText("jLabel8");

        lbl_ratio.setText("jLabel9");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGap(231, 231, 231)
                                .addComponent(jLabel1))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGap(47, 47, 47)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(pb_marron, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pb_gris, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pb_azul, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pb_amarillo, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(57, 57, 57)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(pb_rojo, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pb_verde, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pb_rosa, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pb_naranja, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(25, 25, 25)
                                        .addComponent(jLabel2))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(212, 212, 212)
                                        .addComponent(jLabel3)))
                                .addGap(99, 99, 99)
                                .addComponent(jLabel5))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(56, 56, 56)
                                .addComponent(lbl_jugadas)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lbl_ganadas)
                                .addGap(151, 151, 151)
                                .addComponent(lbl_ratio)
                                .addGap(17, 17, 17)))
                        .addGap(17, 17, 17)))
                .addGap(20, 20, 20))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbl_ganadas)
                            .addComponent(lbl_ratio)))
                    .addComponent(lbl_jugadas))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pb_amarillo, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pb_naranja, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pb_azul, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pb_rosa, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pb_gris, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pb_verde, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pb_marron, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pb_rojo, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JProgressBar jProgressBar10;
    private javax.swing.JProgressBar jProgressBar15;
    private javax.swing.JProgressBar jProgressBar18;
    private javax.swing.JProgressBar jProgressBar8;
    private javax.swing.JLabel lbl_ganadas;
    private javax.swing.JLabel lbl_jugadas;
    private javax.swing.JLabel lbl_ratio;
    private javax.swing.JProgressBar pb_amarillo;
    private javax.swing.JProgressBar pb_azul;
    private javax.swing.JProgressBar pb_gris;
    private javax.swing.JProgressBar pb_marron;
    private javax.swing.JProgressBar pb_naranja;
    private javax.swing.JProgressBar pb_rojo;
    private javax.swing.JProgressBar pb_rosa;
    private javax.swing.JProgressBar pb_verde;
    // End of variables declaration//GEN-END:variables
}
